﻿using Minotaur.App.Domains.Model.Personal;
using Minotaur.App.Domains.Model.Unit;

namespace Minotaur.App.Domains.Model.Organization
{
    [SugarTable("Organization")]
    public class Organization : EntityBase
    {
        [SugarColumn(ColumnName = "autoid", IsIdentity = true, IsPrimaryKey = true)]
        public virtual long AutoId { get; set; }
        [SugarColumn(ColumnName = "orgcode")]
        public virtual string? OrgCode { get; set; }

        [SugarColumn(ColumnName = "parentid")]
        public virtual long? ParentId { get; set; }

        [SugarColumn(ColumnName = "unitid")]
        public virtual long? UnitId { get; set; }

        [SugarColumn(ColumnName = "phone")]
        public virtual string? Phone { get; set; }

        [SugarColumn(ColumnName = "contact")]
        public virtual string? Contact { get; set; }

        [SugarColumn(ColumnName = "sequence")]
        public virtual long? Sequence { get; set; }

        [SugarColumn(ColumnName = "enable")]
        public virtual bool Enable { get; set; }

        [SugarColumn(ColumnName = "havedelete")]
        public virtual bool HaveDelete { get; set; }

        [SugarColumn(ColumnName = "level")]
        public virtual int Level { get; set; }

        /// <summary>
        /// 资源
        /// </summary>
        [Navigate(NavigateType.OneToMany, nameof(OrganizationRes.OrgId))]
        public virtual List<OrganizationRes> Res { get; set; }

        /// <summary>
        /// 职位
        /// </summary>
        [Navigate(NavigateType.OneToMany, nameof(Employee.OrgId))]
        public virtual List<Employee> Employees { get; set; }

        /// <summary>
        /// 职位
        /// </summary>
        [Navigate(NavigateType.OneToMany, nameof(Position.Position.OrgId))]
        public virtual List<Position.Position> Positions { get; set; }
        /// <summary>
        /// 单位
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(UnitId), nameof(UnitInfo.AutoId))]
        public virtual UnitInfo Unit { get; set; }
    }
}
